package com.atung.merchant.mapper;

import com.atung.merchant.dto.StatisticRevenueEntity;
import com.atung.merchant.po.BusMerchantOrder;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@Mapper
public interface BusMerchantOrderMapper extends BaseMapper<BusMerchantOrder> {


    @Select("SELECT\n" +
            "    DATE(creator_time) AS creatorTime,\n" +
            "    SUM(collection) AS totalCollection\n" +
            "FROM\n" +
            "    bus_merchant_order\n" +
            "WHERE\n" +
            "   merchant_id = #{merchantId} AND " +
            " creator_time >= CURDATE() - INTERVAL 7 DAY AND creator_time < CURDATE() + INTERVAL 1 DAY\n" +
            "ORDER BY\n" +
            "    creatorTime ")
    List<StatisticRevenueEntity> queryWeekStatisticRevenue(@Param("merchantId") Long merchantId);
}
